Skip to content

fix: centered image#2762

Open
artem-harbour wants to merge 5 commits intomainfrom
artem/centered-image
Open

fix: centered image#2762
artem-harbour wants to merge 5 commits intomainfrom
artem/centered-image

Conversation

@artem-harbour
Copy link
Copy Markdown
Contributor

@artem-harbour artem-harbour commented Apr 9, 2026

Linear: SD-2469

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: aecf9c4a47

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@artem-harbour
Copy link
Copy Markdown
Contributor Author

@harbournick @caio-pizzol - please review and merge.

The centering math was using the full column width, ignoring paragraph
indents (w:ind). This meant centered/right-aligned inline wpg groups in
indented paragraphs were offset from where Word places them. Now
propagates paragraphAttrs.indent through the drawing block attrs and
subtracts it from the alignment box in layoutDrawingBlock.
Covers all ST_Jc values (left/justify/distribute produce no offset),
non-shapeGroup drawingKind guard (image/vectorShape/chart), missing and
empty wrap guards, oversized group scaling interaction, right alignment
propagation, and left/justify non-propagation in pm-adapter.
Word distributes remaining space equally around single inline content,
which visually centers a sole inline drawing. normalizeAlignment
collapses 'distribute' to 'justify', so we check the raw justification
value from resolvedParagraphProperties to distinguish it from 'both'
(which only stretches inter-word spacing and does not center).
Copy link
Copy Markdown
Contributor

@caio-pizzol caio-pizzol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@artem-harbour fix works for SD-2469. i pushed three small commits on top:

  • indent support — centering now accounts for paragraph indents, matching Word
  • distribute alignmentw:jc="distribute" now centers groups (regular justify stays left), matching Word
  • 7 more unit tests — guards for wrong drawing types, missing wrap, other alignment values, oversized groups

uploaded a 17-case test file to the corpus covering every alignment value + indents + RTL + edge cases. layout and visual tests pick it up automatically.

note: the Codex bot's suggestion to use block.wrap?.type would break the feature — normalizeWrap strips 'Inline' from that field. the current attrs.wrap approach is correct.

all 17 cases verified in dev app against Word.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants